package com.cafe.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.malamute.core.entity.BaseEntity;
import com.malamute.system.entity.FileInSystem;

/**
 * @Description 商品实体
 * @version v1.0
 */
@Entity
@Table(name = "T_CAFE_PRODUCT")
public class Product extends BaseEntity {

	/**
	 * serialVersionUID:TODO（用一句话描述这个变量表示什么）
	 */
	private static final long serialVersionUID = 1L;

	private String name;// 菜单名称

	private float price;// 价格

	private String imageUrl;// 图片地址

	private String description;// 描述
	@ManyToOne(targetEntity = ProductCategory.class, fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinTable(name = "T_PRODUCT_CATEGORY_REL", joinColumns = @JoinColumn(name = "product_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "category_id", referencedColumnName = "id"))
	private ProductCategory productCategory;// 菜单类型

	// // 有中间表关联的manyToOne
	// @ManyToOne(targetEntity = Order.class, fetch = FetchType.LAZY, cascade =
	// CascadeType.REFRESH)
	// @JoinTable(name = "T_PRODUCT_ORDER_REL", joinColumns = @JoinColumn(name =
	// "product_id", referencedColumnName = "id"), inverseJoinColumns =
	// @JoinColumn(name = "order_id", referencedColumnName = "id"))
	// private Order order;// 订单

	@OneToOne(mappedBy = "product",fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	private ProductFile productFile;// 图片文件

	@OneToMany(mappedBy = "product", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Set<OrderProduct> orderProducts;
	
	private boolean isSoldOut=false;//是否下架

	
//	@OneToMany(mappedBy = "product", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
//	private Set<FileInSystem> files;// 
	// private UploadFile uploadFile;

	/**
	 * 获取name
	 * 
	 * @return name
	 */

	public String getName() {
		return name;
	}

	/**
	 * 设置name
	 * 
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 获取price
	 * 
	 * @return price
	 */

	public float getPrice() {
		return price;
	}

	/**
	 * 设置price
	 * 
	 * @param price
	 */
	public void setPrice(float price) {
		this.price = price;
	}

	/**
	 * 获取imageUrl
	 * 
	 * @return imageUrl
	 */

	public String getImageUrl() {
		return imageUrl;
	}

	/**
	 * 设置imageUrl
	 * 
	 * @param imageUrl
	 */
	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}

	/**
	 * 获取description
	 * 
	 * @return description
	 */

	public String getDescription() {
		return description;
	}

	/**
	 * 设置description
	 * 
	 * @param description
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	public ProductCategory getProductCategory() {
		return productCategory;
	}

	public void setProductCategory(ProductCategory productCategory) {
		this.productCategory = productCategory;
	}

	// public Order getOrder() {
	// return order;
	// }
	//
	// public void setOrder(Order order) {
	// this.order = order;
	// }

	public Set<OrderProduct> getOrderProducts() {
		return orderProducts;
	}

	public void setOrderProducts(Set<OrderProduct> orderProducts) {
		this.orderProducts = orderProducts;
	}

	public ProductFile getProductFile() {
		return productFile;
	}

	public void setProductFile(ProductFile productFile) {
		this.productFile = productFile;
	}

	public boolean isSoldOut() {
		return isSoldOut;
	}

	public void setSoldOut(boolean isSoldOut) {
		this.isSoldOut = isSoldOut;
	}

}
